import { Util } from  "./bcat/util/Util";
import {GlobalData } from "./GlobalData";
import {RequestService } from "./bcat/RequestService"

import {ITotpInfo } from "./biz/TotpInfo"



//interface for visit the global data
export class Helper{
  util: Util;
  request: RequestService;
  constructor() {
    this.util = new Util();
    this.request = new RequestService(this.getUrl())
  }

  getUrl(): string{
    return this.util.getAppArgs<GlobalData, string>("url");
  }
  getUserName(): string {
    return this.util.getAppArgs<GlobalData, string>("userName");
  }
  getTotpInfo() : ITotpInfo {
    return this.util.getAppArgs<GlobalData, ITotpInfo>("totpInfo");
  }

  getRequest(){
    const url = this.getUrl(); 
    return this.request.post("/cstool/clear")
      .then((res) => {
        console.log('ok:', res);
        return res;
      })
      .catch((err) => {
        console.log('err:',err);
        return err;
      });
    /*
    my.request({
      url: url + "/cstool/clear",
      method: 'POST',
      success: (res) =>{
        console.log('ok:', res);
      },
      fail: (err) => {
        console.log('err:',err);
      }
    });
    */
  }
}
